package net.atomarrow.util.excel;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.util.CellRangeAddress;

public class ListData extends BaseData{

	private List datas;
	private String[] columns;
	private Map columnMap;
	
	public ListData(int row, int column, List datas, String[] columns, CellStyle CellStyle) {
		super(row, column, CellStyle);
		this.datas=datas;
		this.columns=columns;
	}

	public ListData(int row, int column, List datas2, String[] columns2,
			Map columnMap, CellStyle cellStyle) {
		this(row, column, datas2,columns2,cellStyle);
		this.columnMap=columnMap;
	}

	public List getList(){
		return datas;
	}

	@Override
	public List<CellData> getCellDatas(List<CellRangeAddress> regions) {
		return getCellDatas(regions,null,null);
	}
	
	@Override
	public List<CellData> getCellDatas(List<CellRangeAddress> regions,ExcelFormatListener format,ExcelDataChangeListener dataChanger) {
		processRegions(regions);
		int startColumn = column;
		ArrayList<CellData> cellDatas = new ArrayList<CellData>();
		
		int index=0;
		for(Object data:datas){
			column=startColumn;
			addDomainToList(regions,cellDatas,columnMap,data,columns,index++,format,dataChanger);
			row++;
		}
		return cellDatas;
	}
	


	@Override
	public int getEndColumn() {
		return column-1;
	}

	@Override
	public int getEndRow() {
		return row-1;
	}

}
